



// This code is a generated code by a tool
// designed and coded by Shohdi Mohamed Elsheemy ( shohdi@gmail.com )            

using System;
using System.Collections.Generic;
using System.Web;
using System.Data.Common;
using Shohdi.DataHandler;
using System.Data;




namespace DatabaseComponent
{
    
    public partial class FaqsDB
    {
         string _Connection = "";


        public string Connection
        {
            get { return _Connection; }
            set { _Connection = value; }
        }


       
         string _Provider = "System.Data.SqlClient";

        
        public string Provider
        {
            get { return _Provider; }
            set { _Provider = value; }
        }



        public FaqsDB()
        {
        }

        public FaqsDB(string __Connection,params string [] __Provider)
        {

            if (__Provider.Length > 0)
                _Provider = __Provider[0];

            _Connection = __Connection;
            
        }




        public List<Faqs> Select(ClassDataHandler con, string strTop, string strWhere, params DbParameter[] whereParams)
        {
            if (whereParams == null)
                whereParams = new DbParameter[0];

            List<Faqs> lstRet = new List<Faqs>();

            string strQuery = " select " + strTop  + " * from dbo.[Faqs]  " ;

            if (strWhere != "")
            {
                strQuery = strQuery + "  " + strWhere;
            }

            DbDataReader dr = con.SelectDataReader(strQuery, CommandType.Text, whereParams);


            if (dr.HasRows)
            {
                while (dr.Read())
                {
                    Faqs obj = new Faqs();
 if (dr["ID"] != DBNull.Value)
                    {
                        obj.ID = (System.Int64)dr["ID"];
                    }
                    else
                    {
                        obj.ID = -1;
                    } 
 if (dr["FaqQuestionEN"] != DBNull.Value)
                    {
                        obj.FaqQuestionEN = (System.String)dr["FaqQuestionEN"];
                    }
                    else
                    {
                        obj.FaqQuestionEN = "";
                    } 
 if (dr["FaqQuestionAR"] != DBNull.Value)
                    {
                        obj.FaqQuestionAR = (System.String)dr["FaqQuestionAR"];
                    }
                    else
                    {
                        obj.FaqQuestionAR = "";
                    } 
 if (dr["FaqAnswerEN"] != DBNull.Value)
                    {
                        obj.FaqAnswerEN = (System.String)dr["FaqAnswerEN"];
                    }
                    else
                    {
                        obj.FaqAnswerEN = "";
                    } 
 if (dr["FaqAnswerAR"] != DBNull.Value)
                    {
                        obj.FaqAnswerAR = (System.String)dr["FaqAnswerAR"];
                    }
                    else
                    {
                        obj.FaqAnswerAR = "";
                    } 



                    lstRet.Add(obj);
                   

                }
            }

            dr.Close();


            return lstRet;
        }


        public List<Faqs> Select(string strTop, string strWhere, params DbParameter[] whereParams)
        {
            ClassDataHandler con = new ClassDataHandler(_Connection, _Provider);

            con.OpenConnection();

            List<Faqs> lstRet = Select(con, strTop, strWhere, whereParams);

            con.CloseConnection();

            return lstRet;
        }

        



        public void Insert(ClassDataHandler con , Faqs obj)
        {
            
            

                    DbParameter prmFaqQuestionEN = con.createParameter();
                    prmFaqQuestionEN.ParameterName = "@FaqQuestionEN";
                    prmFaqQuestionEN.DbType =DbType.String;
                    if (obj.FaqQuestionEN == null)
                    {
                        prmFaqQuestionEN.Value = DBNull.Value;
                    }
                    else
                    {
                        prmFaqQuestionEN.Value = obj.FaqQuestionEN;
                    }
                

                    


                    DbParameter prmFaqQuestionAR = con.createParameter();
                    prmFaqQuestionAR.ParameterName = "@FaqQuestionAR";
                    prmFaqQuestionAR.DbType =DbType.String;
                    if (obj.FaqQuestionAR == null)
                    {
                        prmFaqQuestionAR.Value = DBNull.Value;
                    }
                    else
                    {
                        prmFaqQuestionAR.Value = obj.FaqQuestionAR;
                    }
                

                    


                    DbParameter prmFaqAnswerEN = con.createParameter();
                    prmFaqAnswerEN.ParameterName = "@FaqAnswerEN";
                    prmFaqAnswerEN.DbType =DbType.String;
                    if (obj.FaqAnswerEN == null)
                    {
                        prmFaqAnswerEN.Value = DBNull.Value;
                    }
                    else
                    {
                        prmFaqAnswerEN.Value = obj.FaqAnswerEN;
                    }
                

                    


                    DbParameter prmFaqAnswerAR = con.createParameter();
                    prmFaqAnswerAR.ParameterName = "@FaqAnswerAR";
                    prmFaqAnswerAR.DbType =DbType.String;
                    if (obj.FaqAnswerAR == null)
                    {
                        prmFaqAnswerAR.Value = DBNull.Value;
                    }
                    else
                    {
                        prmFaqAnswerAR.Value = obj.FaqAnswerAR;
                    }
                

                    


           



            string strQuery = " insert into dbo.[Faqs] ([FaqQuestionEN],[FaqQuestionAR],[FaqAnswerEN],[FaqAnswerAR]) VALUES (@FaqQuestionEN,@FaqQuestionAR,@FaqAnswerEN,@FaqAnswerAR) ; select SCOPE_IDENTITY() ";
 object scope = con.ExecuteScalar(strQuery, CommandType.Text, prmFaqQuestionEN,prmFaqQuestionAR,prmFaqAnswerEN,prmFaqAnswerAR);


                    try
                    {
                        obj.ID = System.Int64.Parse(scope.ToString());
                    }
                    catch
                    {
                        obj.ID = -1;
                    }


                    


           

        }



        public void Insert(Faqs obj)
        {
            ClassDataHandler con = new ClassDataHandler(_Connection, _Provider);
            con.OpenConnection();

            Insert(con,obj);


            con.CloseConnection();
        }




        public void Update(ClassDataHandler con, Faqs obj)
        {
            
            

                    DbParameter prmID = con.createParameter();
                    prmID.ParameterName = "@ID";
                    prmID.DbType =DbType.Int64;
                    if (obj.ID == null)
                    {
                        prmID.Value = DBNull.Value;
                    }
                    else
                    {
                        prmID.Value = obj.ID;
                    }
                

                    


                    DbParameter prmFaqQuestionEN = con.createParameter();
                    prmFaqQuestionEN.ParameterName = "@FaqQuestionEN";
                    prmFaqQuestionEN.DbType =DbType.String;
                    if (obj.FaqQuestionEN == null)
                    {
                        prmFaqQuestionEN.Value = DBNull.Value;
                    }
                    else
                    {
                        prmFaqQuestionEN.Value = obj.FaqQuestionEN;
                    }
                

                    


                    DbParameter prmFaqQuestionAR = con.createParameter();
                    prmFaqQuestionAR.ParameterName = "@FaqQuestionAR";
                    prmFaqQuestionAR.DbType =DbType.String;
                    if (obj.FaqQuestionAR == null)
                    {
                        prmFaqQuestionAR.Value = DBNull.Value;
                    }
                    else
                    {
                        prmFaqQuestionAR.Value = obj.FaqQuestionAR;
                    }
                

                    


                    DbParameter prmFaqAnswerEN = con.createParameter();
                    prmFaqAnswerEN.ParameterName = "@FaqAnswerEN";
                    prmFaqAnswerEN.DbType =DbType.String;
                    if (obj.FaqAnswerEN == null)
                    {
                        prmFaqAnswerEN.Value = DBNull.Value;
                    }
                    else
                    {
                        prmFaqAnswerEN.Value = obj.FaqAnswerEN;
                    }
                

                    


                    DbParameter prmFaqAnswerAR = con.createParameter();
                    prmFaqAnswerAR.ParameterName = "@FaqAnswerAR";
                    prmFaqAnswerAR.DbType =DbType.String;
                    if (obj.FaqAnswerAR == null)
                    {
                        prmFaqAnswerAR.Value = DBNull.Value;
                    }
                    else
                    {
                        prmFaqAnswerAR.Value = obj.FaqAnswerAR;
                    }
                

                    


           



            string strQuery = " update dbo.[Faqs] set [FaqQuestionEN]=@FaqQuestionEN,[FaqQuestionAR]=@FaqQuestionAR,[FaqAnswerEN]=@FaqAnswerEN,[FaqAnswerAR]=@FaqAnswerAR where  [ID]=@ID  ";

            con.ExecuteNonQuery(strQuery, CommandType.Text,prmID,prmFaqQuestionEN,prmFaqQuestionAR,prmFaqAnswerEN,prmFaqAnswerAR);

            

        }


        public void Update(Faqs obj)
        {
            ClassDataHandler con = new ClassDataHandler(_Connection, _Provider);
            con.OpenConnection();

            Update(con, obj);


            con.CloseConnection();
        }



        public void Delete(ClassDataHandler con, Faqs obj)
        {

            

                    DbParameter prmID = con.createParameter();
                    prmID.ParameterName = "@ID";
                    prmID.DbType =DbType.Int64;
                    if (obj.ID == null)
                    {
                        prmID.Value = DBNull.Value;
                    }
                    else
                    {
                        prmID.Value = obj.ID;
                    }
                

                    


           



           



            string strQuery = " delete from dbo.[Faqs]  where  [ID]=@ID  "; 
                        con.ExecuteNonQuery(strQuery, CommandType.Text,prmID );  

             



        }


        public void Delete( Faqs obj)
        {
            ClassDataHandler con = new ClassDataHandler(_Connection, _Provider);

            con.OpenConnection();

            Delete(con, obj);

            con.CloseConnection();
        }





                    public List<Faqs> getFaqsByID(ClassDataHandler con,System.Int64 ID)
                    {
                        List<Faqs> lstRet = new List<Faqs>();


                        DbParameter prmID = con.createParameter();
                        prmID.ParameterName = "@ID";
                        prmID.DbType = DbType.Int64;
                        if (ID == null)
                        {
                            return lstRet;
                        }
                        else
                        {
                            prmID.Value = ID;
                        }


                        lstRet = Select(con, "" , " where [ID]=@ID ", prmID);



                        return lstRet;

                    }


                    public List<Faqs> getFaqsByID(System.Int64 ID)
                    {
                        List<Faqs> lstRet = new List<Faqs>();

                        ClassDataHandler con = new ClassDataHandler(_Connection, _Provider);
                        con.OpenConnection();

                        lstRet = getFaqsByID(con, ID);

                        con.CloseConnection();

                        return lstRet;

                    }



                

                    public List<Faqs> getFaqsByFaqQuestionEN(ClassDataHandler con,System.String FaqQuestionEN)
                    {
                        List<Faqs> lstRet = new List<Faqs>();


                        DbParameter prmFaqQuestionEN = con.createParameter();
                        prmFaqQuestionEN.ParameterName = "@FaqQuestionEN";
                        prmFaqQuestionEN.DbType = DbType.String;
                        if (FaqQuestionEN == null)
                        {
                            return lstRet;
                        }
                        else
                        {
                            prmFaqQuestionEN.Value = FaqQuestionEN;
                        }


                        lstRet = Select(con, "" , " where [FaqQuestionEN]=@FaqQuestionEN ", prmFaqQuestionEN);



                        return lstRet;

                    }


                    public List<Faqs> getFaqsByFaqQuestionEN(System.String FaqQuestionEN)
                    {
                        List<Faqs> lstRet = new List<Faqs>();

                        ClassDataHandler con = new ClassDataHandler(_Connection, _Provider);
                        con.OpenConnection();

                        lstRet = getFaqsByFaqQuestionEN(con, FaqQuestionEN);

                        con.CloseConnection();

                        return lstRet;

                    }



                

                    public List<Faqs> getFaqsByFaqQuestionAR(ClassDataHandler con,System.String FaqQuestionAR)
                    {
                        List<Faqs> lstRet = new List<Faqs>();


                        DbParameter prmFaqQuestionAR = con.createParameter();
                        prmFaqQuestionAR.ParameterName = "@FaqQuestionAR";
                        prmFaqQuestionAR.DbType = DbType.String;
                        if (FaqQuestionAR == null)
                        {
                            return lstRet;
                        }
                        else
                        {
                            prmFaqQuestionAR.Value = FaqQuestionAR;
                        }


                        lstRet = Select(con, "" , " where [FaqQuestionAR]=@FaqQuestionAR ", prmFaqQuestionAR);



                        return lstRet;

                    }


                    public List<Faqs> getFaqsByFaqQuestionAR(System.String FaqQuestionAR)
                    {
                        List<Faqs> lstRet = new List<Faqs>();

                        ClassDataHandler con = new ClassDataHandler(_Connection, _Provider);
                        con.OpenConnection();

                        lstRet = getFaqsByFaqQuestionAR(con, FaqQuestionAR);

                        con.CloseConnection();

                        return lstRet;

                    }



                

                    public List<Faqs> getFaqsByFaqAnswerEN(ClassDataHandler con,System.String FaqAnswerEN)
                    {
                        List<Faqs> lstRet = new List<Faqs>();


                        DbParameter prmFaqAnswerEN = con.createParameter();
                        prmFaqAnswerEN.ParameterName = "@FaqAnswerEN";
                        prmFaqAnswerEN.DbType = DbType.String;
                        if (FaqAnswerEN == null)
                        {
                            return lstRet;
                        }
                        else
                        {
                            prmFaqAnswerEN.Value = FaqAnswerEN;
                        }


                        lstRet = Select(con, "" , " where [FaqAnswerEN]=@FaqAnswerEN ", prmFaqAnswerEN);



                        return lstRet;

                    }


                    public List<Faqs> getFaqsByFaqAnswerEN(System.String FaqAnswerEN)
                    {
                        List<Faqs> lstRet = new List<Faqs>();

                        ClassDataHandler con = new ClassDataHandler(_Connection, _Provider);
                        con.OpenConnection();

                        lstRet = getFaqsByFaqAnswerEN(con, FaqAnswerEN);

                        con.CloseConnection();

                        return lstRet;

                    }



                

                    public List<Faqs> getFaqsByFaqAnswerAR(ClassDataHandler con,System.String FaqAnswerAR)
                    {
                        List<Faqs> lstRet = new List<Faqs>();


                        DbParameter prmFaqAnswerAR = con.createParameter();
                        prmFaqAnswerAR.ParameterName = "@FaqAnswerAR";
                        prmFaqAnswerAR.DbType = DbType.String;
                        if (FaqAnswerAR == null)
                        {
                            return lstRet;
                        }
                        else
                        {
                            prmFaqAnswerAR.Value = FaqAnswerAR;
                        }


                        lstRet = Select(con, "" , " where [FaqAnswerAR]=@FaqAnswerAR ", prmFaqAnswerAR);



                        return lstRet;

                    }


                    public List<Faqs> getFaqsByFaqAnswerAR(System.String FaqAnswerAR)
                    {
                        List<Faqs> lstRet = new List<Faqs>();

                        ClassDataHandler con = new ClassDataHandler(_Connection, _Provider);
                        con.OpenConnection();

                        lstRet = getFaqsByFaqAnswerAR(con, FaqAnswerAR);

                        con.CloseConnection();

                        return lstRet;

                    }



                

            
public List<Faqs> Search(ClassDataHandler con, Faqs obj)
        {
            string strWhere = "";
            List<DbParameter> lstParameters = new List<DbParameter>();

            
                    if (obj.ID != -1)
                    {
                        DbParameter prmID = con.createParameter();
                        prmID.ParameterName = "@ID";
                        prmID.DbType =DbType.Int64;
                        if (obj.ID == null)
                        {
                            prmID.Value = DBNull.Value;
                        }
                        else
                        {
                            prmID.Value = obj.ID;
                        }
                        strWhere += " [ID]=@ID AND ";
                        lstParameters.Add(prmID);
                     }



                    

                    if (obj.FaqQuestionEN != "")
                    {
                        DbParameter prmFaqQuestionEN = con.createParameter();
                        prmFaqQuestionEN.ParameterName = "@FaqQuestionEN";
                        prmFaqQuestionEN.DbType =DbType.String;
                        if (obj.FaqQuestionEN == null)
                        {
                            prmFaqQuestionEN.Value = DBNull.Value;
                        }
                        else
                        {
                            prmFaqQuestionEN.Value = obj.FaqQuestionEN;
                        }
                        strWhere += " [FaqQuestionEN]=@FaqQuestionEN AND ";
                        lstParameters.Add(prmFaqQuestionEN);
                     }



                    

                    if (obj.FaqQuestionAR != "")
                    {
                        DbParameter prmFaqQuestionAR = con.createParameter();
                        prmFaqQuestionAR.ParameterName = "@FaqQuestionAR";
                        prmFaqQuestionAR.DbType =DbType.String;
                        if (obj.FaqQuestionAR == null)
                        {
                            prmFaqQuestionAR.Value = DBNull.Value;
                        }
                        else
                        {
                            prmFaqQuestionAR.Value = obj.FaqQuestionAR;
                        }
                        strWhere += " [FaqQuestionAR]=@FaqQuestionAR AND ";
                        lstParameters.Add(prmFaqQuestionAR);
                     }



                    

                    if (obj.FaqAnswerEN != "")
                    {
                        DbParameter prmFaqAnswerEN = con.createParameter();
                        prmFaqAnswerEN.ParameterName = "@FaqAnswerEN";
                        prmFaqAnswerEN.DbType =DbType.String;
                        if (obj.FaqAnswerEN == null)
                        {
                            prmFaqAnswerEN.Value = DBNull.Value;
                        }
                        else
                        {
                            prmFaqAnswerEN.Value = obj.FaqAnswerEN;
                        }
                        strWhere += " [FaqAnswerEN]=@FaqAnswerEN AND ";
                        lstParameters.Add(prmFaqAnswerEN);
                     }



                    

                    if (obj.FaqAnswerAR != "")
                    {
                        DbParameter prmFaqAnswerAR = con.createParameter();
                        prmFaqAnswerAR.ParameterName = "@FaqAnswerAR";
                        prmFaqAnswerAR.DbType =DbType.String;
                        if (obj.FaqAnswerAR == null)
                        {
                            prmFaqAnswerAR.Value = DBNull.Value;
                        }
                        else
                        {
                            prmFaqAnswerAR.Value = obj.FaqAnswerAR;
                        }
                        strWhere += " [FaqAnswerAR]=@FaqAnswerAR AND ";
                        lstParameters.Add(prmFaqAnswerAR);
                     }



                    


            if (strWhere != "")
                        strWhere = " where " + strWhere.Substring(0, strWhere.LastIndexOf("AND"));

                    

            

            List<Faqs> lstRet = Select(con, "", strWhere, lstParameters.ToArray());

            return lstRet;
        }


        public List<Faqs> Search(Faqs obj)
        {
            ClassDataHandler con = new ClassDataHandler(_Connection, _Provider);

            con.OpenConnection();

            List<Faqs> lstRet = Search(con,obj);

            con.CloseConnection();

            return lstRet;
        }


                

            
public List<Faqs> SearchOrLike(ClassDataHandler con, Faqs obj)
        {
            string strWhere = "";
            List<DbParameter> lstParameters = new List<DbParameter>();

            
                    if (obj.ID != -1)
                    {
                        DbParameter prmID = con.createParameter();
                        prmID.ParameterName = "@ID";
                        prmID.DbType =DbType.Int64;
                        if (obj.ID == null)
                        {
                            prmID.Value = DBNull.Value;
                        }
                        else
                        {
                            prmID.Value = obj.ID;
                        }
                        strWhere += " [ID]=@ID OR ";
                        lstParameters.Add(prmID);
                     }



                    

                    if (obj.FaqQuestionEN != "")
                    {
                        DbParameter prmFaqQuestionEN = con.createParameter();
                        prmFaqQuestionEN.ParameterName = "@FaqQuestionEN";
                        prmFaqQuestionEN.DbType =DbType.String;
                        if (obj.FaqQuestionEN == null)
                        {
                            prmFaqQuestionEN.Value = DBNull.Value;
                        }
                        else
                        {
                            prmFaqQuestionEN.Value = obj.FaqQuestionEN;
                        }
                        strWhere += " [FaqQuestionEN] LIKE @FaqQuestionEN OR ";
                        lstParameters.Add(prmFaqQuestionEN);
                     }



                    

                    if (obj.FaqQuestionAR != "")
                    {
                        DbParameter prmFaqQuestionAR = con.createParameter();
                        prmFaqQuestionAR.ParameterName = "@FaqQuestionAR";
                        prmFaqQuestionAR.DbType =DbType.String;
                        if (obj.FaqQuestionAR == null)
                        {
                            prmFaqQuestionAR.Value = DBNull.Value;
                        }
                        else
                        {
                            prmFaqQuestionAR.Value = obj.FaqQuestionAR;
                        }
                        strWhere += " [FaqQuestionAR] LIKE @FaqQuestionAR OR ";
                        lstParameters.Add(prmFaqQuestionAR);
                     }



                    

                    if (obj.FaqAnswerEN != "")
                    {
                        DbParameter prmFaqAnswerEN = con.createParameter();
                        prmFaqAnswerEN.ParameterName = "@FaqAnswerEN";
                        prmFaqAnswerEN.DbType =DbType.String;
                        if (obj.FaqAnswerEN == null)
                        {
                            prmFaqAnswerEN.Value = DBNull.Value;
                        }
                        else
                        {
                            prmFaqAnswerEN.Value = obj.FaqAnswerEN;
                        }
                        strWhere += " [FaqAnswerEN] LIKE @FaqAnswerEN OR ";
                        lstParameters.Add(prmFaqAnswerEN);
                     }



                    

                    if (obj.FaqAnswerAR != "")
                    {
                        DbParameter prmFaqAnswerAR = con.createParameter();
                        prmFaqAnswerAR.ParameterName = "@FaqAnswerAR";
                        prmFaqAnswerAR.DbType =DbType.String;
                        if (obj.FaqAnswerAR == null)
                        {
                            prmFaqAnswerAR.Value = DBNull.Value;
                        }
                        else
                        {
                            prmFaqAnswerAR.Value = obj.FaqAnswerAR;
                        }
                        strWhere += " [FaqAnswerAR] LIKE @FaqAnswerAR OR ";
                        lstParameters.Add(prmFaqAnswerAR);
                     }



                    


            if (strWhere != "")
                        strWhere = " where " + strWhere.Substring(0, strWhere.LastIndexOf("OR"));

                    

            

            List<Faqs> lstRet = Select(con, "", strWhere, lstParameters.ToArray());

            return lstRet;
        }


        public List<Faqs> SearchOrLike(Faqs obj)
        {
            ClassDataHandler con = new ClassDataHandler(_Connection, _Provider);

            con.OpenConnection();

            List<Faqs> lstRet = SearchOrLike(con,obj);

            con.CloseConnection();

            return lstRet;
        }


                
        


       
        



    }
}











            